import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/Layout/index.vue'
const constantRouters = [
	{
		path: '/',
		component: Layout,
		redirect: '/home',
		meta: { showTabbar: true },
		children: [
			// 首页
			{
				path: 'home',
				name: 'home',
				component: () => import('@/views/home/index.vue'),
			},
			// 分类
			{
				path: 'classify',
				name: 'classify',
				component: () => import('@/views/classify/index.vue'),
			},
			// 门店
			{
				path: 'shop',
				name: 'shop',
				component: () => import('@/views/shop/index.vue'),
			},
			// 购物车
			{
				path: 'cart',
				name: 'cart',
				component: () => import('@/views/cart/index.vue'),
			},
			// 我的
			{
				path: 'mine',
				name: 'mine',
				component: () => import('@/views/mine/index.vue'),
			}
		]
	},
	// 注册登录
	{
		path: '/reg',
		name: 'reg',
		component: () => import('@/views/register/index.vue')
	},
	{
		path: '/login',
		name: 'login',
		component: () => import('@/views/login/index.vue')
	},
	// 商品列表
	{
		path: '/shopList',
		name: 'shopList',
		component: () => import('@/views/shopList/index.vue')
	},
	// 商品详情
	{
		path: '/goodsInfo',
		name: 'goodsInfo',
		component: () => import('@/views/goodsInfo/index.vue')
	},
	//门店列表
	{
		path: '/storeList',
		name: 'storeList',
		component: () => import("@/views/storeList/index.vue")
	},
	//提交订单
	{
		path: '/orderSub',
		name: 'orderSub',
		component: () => import("@/views/subOrder/index.vue")
	},
	// 提交订单
	{
		path: '/order',
		name: 'order',
		component: () => import('@/views/order/index.vue')
	},
	// 添加地址
	{
		path: '/addAddress',
		name: 'addAddress',
		component: () => import('@/views/addAddress/index.vue')
	},
	// 地址列表
	{
		path: '/addressList',
		name: 'addressList',
		component: () => import('@/views/addressList/index.vue')
	}
]
export const asyncRoutes = [{ path: '/:pathMatch(.*)', redirect: '/404', hidden: true }]
export default createRouter({
	//createWebHashHistory 采用路由hash模式#
	history: createWebHashHistory(),
	//每次进入页面将页面重置到顶部
	scrollBehavior: () => ({ top: 0 }),
	//将静态路由注册到路由上
	routes: constantRouters
})
